/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package chess;

/**
 *
 * @author houfukude
 */
public class whowin{
   static int a[][] = new int[27][27];
   int i=0;

   int whowin(int m, int n,int Bow){
       int x = m + 4;
       int y = n + 4;
       int re = 2;
       if(a[x-2][y-2]!=1&&a[x-2][y-2]!=-1){
           i++;
           a[x-2][y-2] = Bow;
           int[] tmp = new int[15];
           System.out.println("a["+(x-2)+"]["+(y-2)+"]:"+a[x-2][y-2]);
       for(int j=0;j<5;j++){
           int x1 = x+j-2;
           int y1 = y+j-2;
           //System.out.println("a["+x1+"]["+y1+"]"+a[x1][y1]);
           tmp[0] = tmp[0] +a[x1][y-2];
           tmp[1] = tmp[1] +a[x1-1][y-2];
           tmp[2] = tmp[2] +a[x1-2][y-2];
           tmp[3] = tmp[3] +a[x1-3][y-2];
           tmp[4] = tmp[4] +a[x1-4][y-2];

           tmp[5] = tmp[5] +a[x-2][y1];
           tmp[6] = tmp[6] +a[x-2][y1-1];
           tmp[7] = tmp[7] +a[x-2][y1-2];
           tmp[8] = tmp[8] +a[x-2][y1-3];
           tmp[9] = tmp[9] +a[x-2][y1-4];

           tmp[10] = tmp[10] +a[x1][y1];
           tmp[11] = tmp[11] +a[x1-1][y1-1];
           tmp[12] = tmp[12] +a[x1-2][y1-2];
           tmp[13] = tmp[13] +a[x1-3][y1-3];
           tmp[14] = tmp[14] +a[x1-4][y1-4];
       }
       for(int j=0;j<15;j++){
           if(tmp[j]==5){re = 1;}
           if(tmp[j]==-5){re = -1;}
       }
       }else{re = 2;}
       return re;
        
    }

}
